package com.zysdev.openglbeautydemo.filter.addFilter

import android.content.Context
import android.opengl.GLES20
import com.zysdev.openglbeautydemo.R
import com.zysdev.openglbeautydemo.filter.BaseFBOFilter

class BeautyFilter : BaseFBOFilter {
    //这三个是句柄
    private var width: Int = 0
    private var height: Int = 0
    private var opacity: Int = 0

    constructor(context: Context) : super(
        context,
        R.raw.base_vert,
        R.raw.beauty2_frag
    ) {
        //得到变量句柄
        width = GLES20.glGetUniformLocation(program, "width")
        height = GLES20.glGetUniformLocation(program, "height")
        opacity = GLES20.glGetUniformLocation(program, "opacity")

    }

    override fun beforeDraw() {
        super.beforeDraw()
        //使用变量句柄，给变量赋值
        GLES20.glUniform1i(width, mWidth)
        GLES20.glUniform1i(height, mHeight)
        GLES20.glUniform1f(opacity, 0.65f)

    }
}